package com.test;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.utils.QRCodeUtil;

/**
 * Servlet implementation class QrCodeAjaxServlet
 */
@WebServlet("/QrCodeAjaxServlet")
public class QrCodeAjaxServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public QrCodeAjaxServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		//response.getWriter().append("Served at: ").append(request.getContextPath());
		String text = "BEGIN:VCARD \r\n" + 
        		"VERSION:4.0 \r\n" + 
        		"PRODID:ez-vcard 0.9.11 \r\n" + 
        		"N:;张7;;; \r\n" + 
        		//"FN:张三 \r\n" + 
        		"ADR;TYPE=地 址;TZ=UTC+8:;;湖北武汉;;;; \r\n" + 
        		"EMAIL;TYPE=邮 箱;PREF=1: aliyunzixun@xxx.com \r\n" + 
        		"TEL;TYPE=手 机:18953197514 \r\n" + 
        		"TEL;TYPE=固 话:3346959 \r\n" + 
        		"ORG:武汉家里蹲股份有限公司 \r\n" + 
        		//"ROLE:软件开发员 \r\n" + 
        		"TITLE:投研产品事业部 \r\n" + 
        		//"URL:http://www.whjld.com/san.zhang \r\n" + 
        		//"X-QQ:32*****44 \r\n" + 
        		//"X-WEIXIN:zhangsan \r\n" + 
        		//"X-WEIBO:http://weibo.com/zhangsan \r\n" + 
        		"END:VCARD ";
         try {
        	 QRCodeUtil.encode(text, "d:/imgs/timg.jpg", "d:/imgs", true);
         }catch(Exception e) {
        	 e.printStackTrace();
         }
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		//doGet(request, response);
		String text = "BEGIN:VCARD \r\n" + 
        		"VERSION:4.0 \r\n" + 
        		"PRODID:ez-vcard 0.9.11 \r\n" + 
        		"N:;张7;;; \r\n" + 
        		//"FN:张三 \r\n" + 
        		"ADR;TYPE=地 址;TZ=UTC+8:;;湖北武汉;;;; \r\n" + 
        		"EMAIL;TYPE=邮 箱;PREF=1: aliyunzixun@xxx.com \r\n" + 
        		"TEL;TYPE=手 机:18953197514 \r\n" + 
        		"TEL;TYPE=固 话:3346959 \r\n" + 
        		"ORG:武汉家里蹲股份有限公司 \r\n" + 
        		//"ROLE:软件开发员 \r\n" + 
        		"TITLE:投研产品事业部 \r\n" + 
        		//"URL:http://www.whjld.com/san.zhang \r\n" + 
        		//"X-QQ:32*****44 \r\n" + 
        		//"X-WEIXIN:zhangsan \r\n" + 
        		//"X-WEIBO:http://weibo.com/zhangsan \r\n" + 
        		"END:VCARD ";
         try {
        	 QRCodeUtil.encode(text, "d:/imgs/timg.jpg", "d:/imgs", true);
         }catch(Exception e) {
        	 e.printStackTrace();
         }
	}

}
